package com.chagee.store.operation.server.config;

import com.chagee.store.operation.server.model.info.EvaluateDictInfo;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

import java.util.List;
import java.util.Objects;

/**
 * @Author : hk
 * @Date : 2024/4/29
 */

/**
 * 评价项
 */

@Data
@Configuration
@RefreshScope
@ConfigurationProperties(prefix = "evaluate-dict")
public class EvaluateDictConfig {

	/**
	 * 评价枚举
	 */
	private List<EvaluateDictInfo> evaluates;

	public EvaluateDictInfo getByType(String describeCode) {
		EvaluateDictInfo messageInfo = new EvaluateDictInfo();
		for (EvaluateDictInfo info : evaluates) {
			if (Objects.equals(describeCode, info.getEvaluateCode())) {
				BeanUtils.copyProperties(info,messageInfo);
				return messageInfo;
			}
		}
		return null;
	}

}
